<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>计算一个数的阶乘位数多少个零</title>
</head>

<body>
  <script>
    function arr(n) {
      let num = 0;
      let i, j;
      for (i = 5; i <= n; i += 5) {
        j = i;
        while (j % 5 == 0) {
          num++;
          j /= 5;
        }
      }

      return num;
    }
    console.log(arr(5));
  </script>
</body>

</html>